<template>
	<div class="w-80 m-auto text-center" v-loading="data.mtloading">
		<el-form-item :label="$t('public.unbind')+':'" v-if="props.info.openid">
			<el-switch @change="changeSwitch" v-model="radioValue" inline-prompt :active-text="$t('public.yes')" :inactive-text="$t('public.no')" />
		</el-form-item>
		<span v-if="data.unData">{{ data.unData }}</span>
		<img v-else class="max-w-80 min-w-80 max-h-80 min-h-80 " :src="data.url" fit="fill" />
	</div>
</template>
<script lang="ts" setup>
import { useI18n } from 'vue-i18n' 
const { t: $t } = useI18n()
import { bindWxauthmanager } from '@/api/account';
import { ref } from 'vue'
let emit = defineEmits(['investigate'])
const radioValue = ref(false)
let props = defineProps({
	info: {
		type: Object,
		default: {}
	}
})
let data = reactive({
	mtloading: false, // 加载
	url: '',
	unData:''
})
let changeSwitch = (value)=>{
	let parm ={
		manager_id:props.info.manager_id,
		unbind: value? 1 : 0
	}
	findBindWxauthmanager(parm)
}
let findBindWxauthmanager = (parm)=>{
	bindWxauthmanager(parm).then(res => {
		data.mtloading = false
		if (res.state == 200) {
			data.url = res.data
		}
	}).catch(err=>{
		data.mtloading = false
		data.unData = $t('public.unData')
	})
}
let getinfo = () => {
	let parm ={
		manager_id:props.info.manager_id
	}
	data.mtloading = true
	findBindWxauthmanager(parm)
}
getinfo()
</script>
